package com.analyse.stock.enums;

import org.apache.commons.lang3.StringUtils;

public enum HolidayEnum {
    NEWYEARDAY("NEWYEARDAY",1,"元旦节"),
    CHINESENEWYEARGREGORIANFESTIVAL("CHINESENEWYEARGREGORIANFESTIVAL",8,"春节"),
    QINGMINGFESTIVAL("QINGMINGFESTIVAL",3,"清明节"),
    LABORDAY("LABORDAY",5,"劳动节"),
    DRAGONBOATGREGORIANFESTIVAL("DRAGONBOATGREGORIANFESTIVAL",3,"端午节"),
    MIDAUTUMNGREGORIANFESTIVAL("MIDAUTUMNGREGORIANFESTIVAL",3,"中秋节"),
    NATIONALDAY("NATIONALDAY",8,"国庆节"),
   ;
    HolidayEnum(String code,Integer day, String desc) {
        this.code = code;
        this.desc = desc;
        this.day = day;
    }

    private final String code;
    private int day;
    private final String desc;

    public String getCode() {
        return this.code;
    }
    public Integer getDay() {
        return  this.day;
    }
    public String getDesc() {
        return  this.desc;
    }


    public static String getDescByCode(String code){
        if(StringUtils.isBlank(code)) {
            return StringUtils.EMPTY;
        }
        for (HolidayEnum anEnum : values()) {
            if (anEnum.getCode().equalsIgnoreCase(code)){
                return anEnum.getDesc();
            }
        }
        return StringUtils.EMPTY;
    }

    public static String getByName(String name){
        if(StringUtils.isBlank(name)) {
            return StringUtils.EMPTY;
        }
        for (HolidayEnum anEnum : values()) {
            if (anEnum.name().contains(name.toUpperCase())){
                return anEnum.getCode();
            }
        }
        return StringUtils.EMPTY;
    }
}
